//
// Created by 123 on 2025/1/6.
//
#include "iostream"
using namespace std;

template<class T1,class T2> class Person;

template<class T1, class T2>
void printPerson2(Person<T1,T2>& p){
    cout << "class out:" <<  "name=" << p.name << " age:" << p.age << endl;
}

template<class T1,class T2>
class Person{
    //1-全局函数配合友元 类内实现
    friend void printPerson(Person<T1,T2>& p){
        cout << "name=" << p.name << " age:" << p.age << endl;
    }
    //2-全局函数配合友元，类外实现
    friend void printPerson2<>(Person<T1,T2>& p);
private:
    T1 name;
    T2 age;
public:
    Person(T1 name,T2 age){
        this->name = name;
        this->age = age;
    }
};

void test1(){
    Person<string,int> p("jerry",133);
    printPerson(p);
}

void test2(){
    Person<string,int> p("jerry",133);
    printPerson2(p);
}




int main107(){
    test1();
    test2();

    return 0;
}